package com.example.administrator.jingpingou.bean;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 小吧 on 2016/8/29.
 */
public class Shop_Data {

    /**
     * rp_type : 103
     * num_iid : 41663117332
     * yhq_url :
     * yhq_price :
     * deal_num : 1000
     * title : 旅行防水多功能洗漱包内衣收纳化妆包文胸整理袋便携式整理收纳盒
     * pic_url : http://gd1.alicdn.com/imgextra/i1/86738228/TB2IdP.aFXXXXXhXXXXXXXXXXXX_!!86738228.jpg
     * qiangpai : 0
     * now_price : 9.9
     * show_time : today ads
     * origin_price : 38
     * discount : 2.6
     * start_discount : 2016-08-29 00:00:00
     * is_vip_price : 1
     * ling_value : 1
     * is_onsale : 1
     * total_love_number : 0
     * total_hate_number : 0
     * is_buy_sale : 1
     */

    private List<ListYan> list;

    public static Shop_Data objectFromData(String str) {

        return new Gson().fromJson(str, Shop_Data.class);
    }

    public static Shop_Data objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), Shop_Data.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<Shop_Data> arrayShop_DataFromData(String str) {

        Type listType = new TypeToken<ArrayList<Shop_Data>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<Shop_Data> arrayShop_DataFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<Shop_Data>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public List<ListYan> getList() {
        return list;
    }

    public void setList(List<ListYan> list) {
        this.list = list;
    }

    public static class ListYan {
        private String rp_type;
        private String num_iid;
        private String yhq_url;
        private String yhq_price;
        private String deal_num;
        private String title;
        private String pic_url;
        private String qiangpai;
        private double now_price;
        private String show_time;
        private float origin_price;
        private double discount;
        private String start_discount;
        private int is_vip_price;
        private int ling_value;
        private int is_onsale;
        private int total_love_number;
        private int total_hate_number;
        private int is_buy_sale;

        public static ListYan objectFromData(String str) {

            return new Gson().fromJson(str, ListYan.class);
        }

        public static ListYan objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), ListYan.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<ListYan> arrayListYanFromData(String str) {

            Type listType = new TypeToken<ArrayList<ListYan>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<ListYan> arrayListYanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<ListYan>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public String getRp_type() {
            return rp_type;
        }

        public void setRp_type(String rp_type) {
            this.rp_type = rp_type;
        }

        public String getNum_iid() {
            return num_iid;
        }

        public void setNum_iid(String num_iid) {
            this.num_iid = num_iid;
        }

        public String getYhq_url() {
            return yhq_url;
        }

        public void setYhq_url(String yhq_url) {
            this.yhq_url = yhq_url;
        }

        public String getYhq_price() {
            return yhq_price;
        }

        public void setYhq_price(String yhq_price) {
            this.yhq_price = yhq_price;
        }

        public String getDeal_num() {
            return deal_num;
        }

        public void setDeal_num(String deal_num) {
            this.deal_num = deal_num;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getPic_url() {
            return pic_url;
        }

        public void setPic_url(String pic_url) {
            this.pic_url = pic_url;
        }

        public String getQiangpai() {
            return qiangpai;
        }

        public void setQiangpai(String qiangpai) {
            this.qiangpai = qiangpai;
        }

        public double getNow_price() {
            return now_price;
        }

        public void setNow_price(double now_price) {
            this.now_price = now_price;
        }

        public String getShow_time() {
            return show_time;
        }

        public void setShow_time(String show_time) {
            this.show_time = show_time;
        }

        public float getOrigin_price() {
            return origin_price;
        }

        public void setOrigin_price(float origin_price) {
            this.origin_price = origin_price;
        }

        public double getDiscount() {
            return discount;
        }

        public void setDiscount(double discount) {
            this.discount = discount;
        }

        public String getStart_discount() {
            return start_discount;
        }

        public void setStart_discount(String start_discount) {
            this.start_discount = start_discount;
        }

        public int getIs_vip_price() {
            return is_vip_price;
        }

        public void setIs_vip_price(int is_vip_price) {
            this.is_vip_price = is_vip_price;
        }

        public int getLing_value() {
            return ling_value;
        }

        public void setLing_value(int ling_value) {
            this.ling_value = ling_value;
        }

        public int getIs_onsale() {
            return is_onsale;
        }

        public void setIs_onsale(int is_onsale) {
            this.is_onsale = is_onsale;
        }

        public int getTotal_love_number() {
            return total_love_number;
        }

        public void setTotal_love_number(int total_love_number) {
            this.total_love_number = total_love_number;
        }

        public int getTotal_hate_number() {
            return total_hate_number;
        }

        public void setTotal_hate_number(int total_hate_number) {
            this.total_hate_number = total_hate_number;
        }

        public int getIs_buy_sale() {
            return is_buy_sale;
        }

        public void setIs_buy_sale(int is_buy_sale) {
            this.is_buy_sale = is_buy_sale;
        }
    }
}
